package com.activities;

import org.json.JSONException;
import org.json.JSONObject;

import com.bean.refute;
import com.example.lizhiinformation.R;
import com.ownload.Httputil;
import com.ownload.Httputil.OnNetWorkBitmpResponse;
import com.ownload.Httputil.OnNetWorkRespones;
import com.tools.Path_URL;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 真相帝类型
 * 
 * @author Administrator
 * 
 */
public class Zhengxiangdi_items extends Activity {

	private TextView truthcontent;
	private TextView truthtitle;
	private ImageView truthimage;
	private TextView rumortitle;
	private TextView rumorcontent;
	private ImageView rumorimage;
	private refute refute;
	private TextView origin;
	private Button back;
	private Button comment;
	private String extra;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_zhengxiangdi_items);
		Intent intent = getIntent();
		 extra = intent.getStringExtra("url");
		truthcontent = (TextView) findViewById(R.id.truthcontent);
		truthtitle = (TextView) findViewById(R.id.truthtitle);
		truthimage = (ImageView) findViewById(R.id.truthimage);
		rumortitle = (TextView) findViewById(R.id.rumortitle);
		rumorcontent = (TextView) findViewById(R.id.rumortextview);
		rumorimage = (ImageView) findViewById(R.id.rumorimage);
		origin = (TextView) findViewById(R.id.origin);
		back = (Button) findViewById(R.id.zhenxiangdi_back);
		comment = (Button) findViewById(R.id.zhenxiangdi_comment);
		footbutton();
		frame();
		

	}
	/**
	 * 框架及数据处理
	 */
public void frame(){
	Httputil.OnWorkDown(Path_URL.ZHANGXIANGDI_ITEMS + extra
			+ Path_URL.ZHANGXIANGDI_ITEMS2, new OnNetWorkRespones() {

		@Override
		public void OK(String respose) {
			// TODO Auto-generated method stub
			try {
				JSONObject object = new JSONObject(respose);
				JSONObject object2 = object.getJSONObject("paramz")
						.getJSONObject("refute");
				refute = new refute();
				refute.setContents(object2.getString("contents"));
				refute.setCover(object2.getString("cover"));
				refute.setFact(object2.getString("fact"));
				refute.setOrigin(object2.getString("origin"));
				refute.setPhoto(object2.getString("photo"));
				refute.setSubject(object2.getString("subject"));
				refute.setTruth(object2.getString("truth"));
				rumortitle.setText(refute.getSubject());
				rumorcontent.setText("\t" + "\t" + refute.getContents());
				Httputil.OnworkBitmaDown(
						Path_URL.IMAGEURL + refute.getCover(),
						new OnNetWorkBitmpResponse() {

							@Override
							public void OK(Bitmap bitmap) {
								// TODO Auto-generated method stub
								rumorimage.setImageBitmap(bitmap);
							}

							@Override
							public void ERROR(String error) {
								// TODO Auto-generated method stub

							}
						});
				origin.setText(refute.getOrigin());
				truthtitle.setText(refute.getTruth());
				truthcontent.setText("\t" + "\t" + refute.getFact());
				Httputil.OnworkBitmaDown(
						Path_URL.IMAGEURL + refute.getPhoto(),
						new OnNetWorkBitmpResponse() {

							@Override
							public void OK(Bitmap bitmap) {
								// TODO Auto-generated method stub
								truthimage.setImageBitmap(bitmap);
							}

							@Override
							public void ERROR(String error) {
								// TODO Auto-generated method stub

							}
						});

			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		@Override
		public void ERROR(String error) {
			// TODO Auto-generated method stub

		}
	});
}
	public void footbutton() {
		back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Zhengxiangdi_items.this.finish();
			}
		});
		comment.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(Zhengxiangdi_items.this,
						Comment.class);
				startActivity(intent);
			}
		});
	}

}
